#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  double arr[100][100]={},b[100][100]={};
  int i,j;
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
        cin>>arr[i][j];
}  
}
  for(i=0;i<n;i++){
    for(j=0;j<m;j++)
      if(i!=0&&j!=0&&i!=n-1&&j!=m-1)
        b[i][j]=round((arr[i-1][j]+arr[i][j-1]+arr[i][j+1]+arr[i+1][j]+arr[i][j])/5);
      else  
        b[i][j]=arr[i][j];
    }
    for(i=0;i<n;i++){
      for(j=0;j<m;j++)
        cout<<b[i][j]<<" ";
      cout<<endl;
  }
}
